import java.util.Stack;

/**
 * 两个栈实现队列
 */
public class Solution9 {

    private Stack<Integer> in = new Stack<>();
    private Stack<Integer> out = new Stack<>();

    public void push(int node){
        in.push(node);
    }

    public int pop() throws Exception{
        while (out.isEmpty()){
            if (!in.isEmpty()){
                out.push(in.pop());
            }
            else
                throw new Exception("queue is empty!");
        }

        return out.pop();
    }

//    public static void main(String[] args) throws Exception {
//        Solution9 s9 = new Solution9();
//        s9.in.push(1);
//        System.out.println(s9.pop());
//        System.out.println(s9.pop());
//    }
}
